 <%= javascript_include_tag "prototype" %>
<script src="/javascripts/util.js" type="text/javascript"></script>
<script src="/javascripts/calendar.js" type="text/javascript"></script>
<script language="JavaScript" type="text/JavaScript">
        function checkPWD(flag){
                if (flag) {
                        if ($("account_password").value != "")
                        {
                                if ($("account_password").value.length<5 || $("account_password").value.length>10)
                                {
                                        $("pwd").innerText = "密码必须为5到10个字符";
                                        $("pwd").style.display = "block";
                                        return false;
                                }
                                else if ($("account_password").value != "" && amountCheck($("account_password").value) )
                                {
                                        $("pwd").innerText = "密码安全程度：弱";
                                        $("pwd").style.display = "block";
                                        return true;      
                                }
                                else return true;
                        }
                        else {
                                $("pwd").innerText = "请输入5到10位的密码";
                                $("pwd").style.display = "block";
                                return false;      
                        }
                }
                else {
                        $("pwd").style.display = "none";
                }
        }
        function checkPWD1(flag){
                if (flag) {
                        if ($("account_password").value != "" && $("account_password").value != $("account_password_confirmation").value )
                        {
                                $("pwdConfirm").innerText = "两次输入密码不一致";
                                $("pwdConfirm").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("pwdConfirm").style.display = "none";
                }
        }
        function checkName(flag){
                if (flag) {
                        if ($("employee_name").value == "")
                        {
                                $("id_name").innerText = "姓名不可为空";
                                $("id_name").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_name").style.display = "none";
                }
        }
        function checkMail(flag){
                if (flag) {
                        if ($("employee_email").value != "" && ! checkEmail($("employee_email").value))
                        {
                                $("id_email").innerText = "邮件地址不正确";
                                $("id_email").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_email").style.display = "none";
                }
        }

	function checkForm(){
                return checkName(true) && checkPWD(true) && checkPWD1(true) && checkMail(true);
	}
</script>
<h1>员工管理 - <span id="secondHeading">创建员工</span></h1>
<form name="employeeForm" action="/adminorg/add_employee" enctype="multipart/form-data" method="post" id="input-form">
<TABLE border="0" id="INPUT_TABLE">
	<TR>
		<TD colspan="2">
			<% if @flash[:notice] -%>
			<div id="notice"><%= @flash[:notice] %></div>
			<% end -%>
			<% if @account and error_messages_for(:account) %>
			<%=error_messages_for(:account)%>
			<% end %>
		</TD>
	</TR>
	<TR>
		<TD>姓名：</TD>
		<TD><input id="employee_name" name="employee[name]" type="text" value=""  maxlength="20" onfocus="checkName(false)" onblur="checkName(true)"/>          <em>*</em> <div class="redNsg" id="id_name" style="display:none;"></div></TD>
	</TR>
	<TR>
		<TD>密码：</TD>
		<TD><input id="account_password" name="account[password]" type="password"  maxlength="20" onfocus="checkPWD(false)" onblur="checkPWD(true)"/>          <em>*</em>  <div class="redNsg" id="pwd" style="display:none;"></div></TD>
	</TR>
	<TR>
		<TD>确认密码：</TD>
		<TD><input id="account_password_confirmation" name="account_password_confirmation" type="password" maxlength="20" onfocus="checkPWD1(false)" onblur="checkPWD1(true)"/>          <em>*</em>  <div class="redNsg" id="pwdConfirm" style="display:block;"></div></TD>
	</TR>
	<TR>
		<TD>所属角色：</TD>
		<TD><%=collection_select(:account, :role_id, @roles, :id, :name)%></TD>
	</TR>
	<TR>
		<TD>照片：</TD>
		<TD>
		<!--<%= file_field("employee", "photo") %>
		<input id="employee_photo" name="employee[photo]" type="text" value="" />
		-->	
		<%= file_column_field "employee", "photo" %>
		</TD>
	</TR>
	<TR>
		<TD>英文名：</TD>
		<TD><input id="employee_english_name" name="employee[english_name]" type="text" value=""  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>性别：</TD>
		<TD><%=select(:employee,:sex,[['男',1],['女',0]])%></TD>
	</TR>
	<TR>
		<TD>生日：</TD>
                <TD>
                        <!--<%=date_select(:employee,:birthday_at,:order=>[:year,:month,:day],:use_month_numbers => true,:start_year=>1960)%> -->
                        <script language=javascript>
                                var bir_Date=new dateSelector();
                                bir_Date.inputID='birthday_at';
                                bir_Date.inputName='employee[birthday_at]';
                                bir_Date.display();
                        </script>
                </TD>
	</TR>
	<TR>
		<TD>婚姻状况：</TD>
		<TD><input id="employee_married" name="employee[married]" type="checkbox" value="1" /></TD>
	</TR>
	<TR>
		<TD>分机号码：</TD>
		<TD><input id="employee_ext" name="employee[ext]" type="text" value=""  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>固定电话：</TD>
		<TD><input id="employee_phone" name="employee[phone]" type="text" value=""  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>原籍电话：</TD>
		<TD><input id="employee_ori_phone" name="employee[ori_phone]" type="text" value="" maxlength="20" /></TD>
	</TR>
	<TR>
		<TD>手机：</TD>
		<TD><input id="employee_mobile" name="employee[mobile]" type="text" value="" maxlength="20" /></TD>
	</TR>
	<TR>
		<TD>小灵通：</TD>
		<TD><input id="employee_lingtong" name="employee[lingtong]" type="text" value="" maxlength="20" /></TD>
	</TR>
	<TR>
		<TD>电子邮件：</TD>
		<TD><input id="employee_email" name="employee[email]" type="text" value="" maxlength="20" onfocus="checkMail(false)" onblur="checkMail(true)" /> <div class="redNsg" id="id_email" style="display:none;"></TD>
	</TR>
	<TR>
		<TD>备注：</TD>
		<TD><textarea id="employee_resume" name="employee[resume]" cols="50" rows="5"></textarea></TD>
	</TR>
	<TR>
		<TD colspan="2" align="right">
			<input name="commit" type="submit" value="添加" class="sub" onclick="javascript:return checkForm();"/>&nbsp;OR&nbsp;<input type="reset" value="重新填写" class="cal"></TD>
	</TR>
</table>
 <p class="note"> <strong class="alert">注意：</strong><br/>
 一、有 <em>*</em> 标记的是必填项。<br/>二、密码长度6～20位，由英文字母a～z (区分大小写)，数字0～9，特殊字符组成。<br/>　　如果您输入的密码安全程度较弱也可以通过验证。
 </p>
<%= end_form_tag %>
